﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Calculator_w
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e){}

        private void cal_button_Click(object sender, EventArgs e)
        {
            double num1 = Convert.ToDouble(textBox1.Text);
            double num2 = Convert.ToDouble(textBox2.Text);
            object type = comboBox1.SelectedItem;
            double res = 0;
            switch (type.ToString())
            {
                case "+":
                    res = num1 + num2;
                    break;
                case "-":
                    res = num1 - num2;
                    break;
                case "x":
                    res = num1 * num2;
                    break;
                case "/":
                    if (num2 == 0) goto default;
                    res = num1 / num2;
                    break;
                default:
                    output.Text = ("Error");
                    return;
            }
            output.Text = (res.ToString());
            return;
        }

        private void zero_Click(object sender, EventArgs e)
        {
            textBox1.Text = "0";
            textBox2.Text = "0";
            output.Text = "0";
            comboBox1.Text = " ";
        }

    }
}
